uniapp地图自定义组件拖拽获取中心经纬度 |
您所在的位置:网站首页 › uniapp 地图选点 › uniapp地图自定义组件拖拽获取中心经纬度 |
@regiοnchange="regionchange" : 地图滑动调用的方法 regionchange(event) { console.log('regionchange', event) if(event.type =='end'){ this.getCenterLanLat() } }, // 获取当前地图中心的经纬度 getCenterLanLat() { this.mapContext = uni.createMapContext("maps", this); console.log('获取中心点', this.mapContext) this.mapContext.getCenterLocation({ type: 'gcj02', success: (res) => { let address = { latitude: res.latitude, longitude: res.longitude } this.markers[0].longitude = address.longitude; this.markers[0].latitude = address.latitude; this.$emit('longLatDetail', address) }, fail:(err)=>{ console.log(this.latitude) console.log('获取当前地图中心的经纬度2', err); } }) },注意:这个地图组件是我自定义的组件,所以获取this.mapContext = uni.createMapContext("maps", this);必须传入this,否则获取不到地图中心的经纬度 this.mapContext = uni.createMapContext("maps", this);
|
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |